package com.ikas.ai.enums.redis;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MessageFormatter;

/**
 * @author hubowei
 * @email hu.bowei@ikasinfo.com
 * @date 2023-11-6 19:25:23
 */
public class RedisKeyUtil {

	/**
	 * 动态生成redis key
	 * 
	 * @param format
	 * @param argArray
	 * @return
	 */
	public static String generateKey(String format, Object... argArray) {
		// 判断如果参数format未空，则返回空
		if (StringUtils.isEmpty(format)) {
			return "";
		}
		// 调用slf4j的format方法
		FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
		return ft.getMessage();
	}
}
